﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsTest.Public
{
    public class OperatorButton
    {
        OperatorLabelEnum operatorLabelEnum;
        OperatorModel operatorModel;
        Panel ownerPanel = null;
        MainForm mainForm=null;

        public OperatorButton(OperatorLabelEnum operatorLabelEnum, Panel ownerPanel, MainForm mainForm)
        {
            this.operatorLabelEnum = operatorLabelEnum;

            operatorModel = (OperatorModel)(Operator.hashTable[operatorLabelEnum]);
            this.ownerPanel = ownerPanel;
            this.mainForm = mainForm;
        }
        
        public  void Create_Operator_Btn()
        {
            Button button = new System.Windows.Forms.Button();
            button.BackColor = System.Drawing.Color.Transparent;
            button.BackgroundImage = operatorModel.BGImager;
            button.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            button.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            button.Location = new System.Drawing.Point(3, 89);
            button.Name = "opButton" + operatorLabelEnum;
            button.Size = new System.Drawing.Size(80, 80);
            button.TabIndex = 9;
            button.Text = operatorModel.Label;
            button.UseVisualStyleBackColor = false;
            button.Click += new System.EventHandler(button_Click);
            
            ownerPanel.Controls.Add(button);
           

        }

        private  void button_Click(object sender, EventArgs e)
        {
            Operator.Create_MainTabPage(operatorLabelEnum, operatorModel.windowModel,mainForm);
        }
    }
}
